package com.qingcheng.dao;

import com.qingcheng.domain.PageVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface StockMapper {
    /**
     * 查询入库
     */
    @Select("<script>SELECT sku.id,sku.image,sku.name,sku.brand_name,spu.sn,sku.spec,ol.order_id,sku.num,ol.operater,DATE_FORMAT(ol.operate_time,'%Y-%m-%d %H:%i:%s') operate_time FROM tb_sku sku\n" +
            "INNER JOIN tb_spu spu ON sku.spu_id=spu.id\n" +
            "LEFT JOIN qingcheng_order.`tb_return_order_item` roi ON sku.id = roi.sku_id\n" +
            "LEFT JOIN qingcheng_order.`tb_order_log` ol ON roi.order_id = ol.order_id where spu.status=1\n" +
            "AND sku.status=1 " +
            "<if test='name!=null and name!=\"\"'>and sku.name like '%${name}%'</if>" +
            "<if test='date1!=null and date1!=\"\"'>and operate_time like '${date1}%'</if>" +
            "</script>")
    List<Map> findAllStock(@Param("name") String name, @Param("date1") String date1);
    /**
     * 查询出库
     */

    @Select("<script>SELECT sku.id,sku.image,sku.name,sku.brand_name,sku.spec,ol.order_id,sku.num,ol.operater,DATE_FORMAT(ol.operate_time,'%Y-%m-%d %H:%i:%s') operate_time FROM tb_sku sku\n" +
            "INNER JOIN qingcheng_order.`tb_order_item` oi\t\n" +
            "ON oi.sku_id=sku.id\n" +
            "INNER JOIN qingcheng_order.`tb_order_log` ol \n" +
            "ON ol.order_id=oi.order_id" +
            "<where>" +
            "<if test='name!=null and name!=\"\"'>and sku.name like '%${name}%'</if>" +
            "<if test='date1=null and date1!=\"\"'>and operate_time like '${date1}%'</if>" +
            "</where>" +
            "</script>")
    List<Map> findOutStock(@Param("name") String name, @Param("date1") String date1);

}
